package com.iqik.mongo;

import com.iqik.mongo.pojo.Resume;
import com.iqik.mongo.repository.ResumeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.util.List;
import java.util.Random;

@SpringBootApplication
public class MongoShardingApplication {

    private final static String[] CITYS = {"北京", "上海", "天津", "重庆", "广州", "深圳", "成都", "武汉"};
    private final static String[] NAMES = {""};

    public static void main(String[] args) {
        ApplicationContext applicationContext = SpringApplication.run(MongoShardingApplication.class, args);
        ResumeRepository repository = applicationContext.getBean(ResumeRepository.class);
        for (int i = 40; i < 80; i++) {
            Resume resume  = new Resume();
            resume.setName("test"+i);
            resume.setExpectSalary(25555);
            resume.setCity(CITYS[new Random().nextInt(CITYS.length)]);
            repository.save(resume);
        }

//        List<Resume> resumes = repository.findAll();
//        resumes.forEach(resume -> {
//            System.out.println(resume.toString());
//        });

    }
}
